<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE infinitus_campannas SET titulo=%s, pais=%s, minombre=%s, micorreo=%s, url_redirigir_suscribir=%s, url_redirigir_suscribir_error=%s, url_enlace_afiliados=%s, niveles=%s, smtp_servidor=%s, smtp_puerto=%s, smtp_usuario=%s, smtp_clave=%s, smtp_usar_ssl=%s ,asunto_correo_inicial=%s, html_correo_inicial=%s WHERE idcampanna=%s",
                       GetSQLValueString($_POST['titulo'], "text"),
                       GetSQLValueString($_POST['pais'], "text"),
                       GetSQLValueString($_POST['minombre'], "text"),
                       GetSQLValueString($_POST['micorreo'], "text"),
                       GetSQLValueString($_POST['url_redirigir_suscribir'], "text"),
                       GetSQLValueString($_POST['url_redirigir_suscribir_error'], "text"),
                       GetSQLValueString($_POST['url_enlace_afiliados'], "text"),
                       GetSQLValueString($_POST['niveles'], "int"),
                       GetSQLValueString($_POST['smtp_servidor'], "text"),
                       GetSQLValueString($_POST['smtp_puerto'], "text"),
                       GetSQLValueString($_POST['smtp_usuario'], "text"),
                       GetSQLValueString($_POST['smtp_clave'], "text"),
                       GetSQLValueString($_POST['smtp_usar_ssl'], "int"),
                       GetSQLValueString($_POST['asunto_correo_inicial'], "text"),
                       GetSQLValueString($_POST['html_correo_inicial'], "text"),
                       GetSQLValueString($_POST['idcampanna'], "int"));

  mysql_select_db($database_Infinitus, $Infinitus);
  $Result1 = mysql_query($updateSQL, $Infinitus) or die(mysql_error());

  $updateGoTo = "campannas_listado_vista.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_rsCampanna = "-1";
if (isset($_GET['idcampanna'])) {
  $colname_rsCampanna = $_GET['idcampanna'];
}
mysql_select_db($database_Infinitus, $Infinitus);
$query_rsCampanna = sprintf("SELECT * FROM infinitus_campannas WHERE idcampanna = %s", GetSQLValueString($colname_rsCampanna, "int"));
$rsCampanna = mysql_query($query_rsCampanna, $Infinitus) or die(mysql_error());
$row_rsCampanna = mysql_fetch_assoc($rsCampanna);
$totalRows_rsCampanna = mysql_num_rows($rsCampanna);

mysql_free_result($rsCampanna);
?>

<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table width="569" align="center">
    <tr valign="baseline">
      <td nowrap align="right">Titulo:</td>
      <td><input type="text" name="titulo" value="<?php echo htmlentities($row_rsCampanna['titulo'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Pais:</td>
      <td><input type="text" name="pais" value="<?php echo htmlentities($row_rsCampanna['pais'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Minombre:</td>
      <td><input type="text" name="minombre" value="<?php echo htmlentities($row_rsCampanna['minombre'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Micorreo:</td>
      <td><input type="text" name="micorreo" value="<?php echo htmlentities($row_rsCampanna['micorreo'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Url_redirigir_suscribir:</td>
      <td><input type="text" name="url_redirigir_suscribir" value="<?php echo htmlentities($row_rsCampanna['url_redirigir_suscribir'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Url_redirigir_suscribir error</td>
      <td><input type="text" name="url_redirigir_suscribir_error" value="<?php echo htmlentities($row_rsCampanna['url_redirigir_suscribir_error'], ENT_COMPAT, ''); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">url enlace afiliato</td>
      <td><input type="text" name="url_enlace_afiliados" value="<?php echo htmlentities($row_rsCampanna['url_enlace_afiliados'], ENT_COMPAT, ''); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Niveles:</td>
      <td><input type="text" name="niveles" value="<?php echo htmlentities($row_rsCampanna['niveles'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Smtp_servidor:</td>
      <td><input type="text" name="smtp_servidor" value="<?php echo htmlentities($row_rsCampanna['smtp_servidor'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Smtp_puerto:</td>
      <td><input type="text" name="smtp_puerto" value="<?php echo htmlentities($row_rsCampanna['smtp_puerto'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Smtp_usuario:</td>
      <td><input type="text" name="smtp_usuario" value="<?php echo htmlentities($row_rsCampanna['smtp_usuario'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Smtp_clave:</td>
      <td><input type="text" name="smtp_clave" value="<?php echo htmlentities($row_rsCampanna['smtp_clave'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Smtp_usar_ssl:</td>
      <td><input type="text" name="smtp_usar_ssl" value="<?php echo htmlentities($row_rsCampanna['smtp_usar_ssl'], ENT_COMPAT, ''); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Correo inicial</td>
      <td><input name="asunto_correo_inicial" type="text" id="asunto_correo_inicial" value="<?php echo htmlentities($row_rsCampanna['asunto_correo_inicial']); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Correo inicial al suscribirse</td>
      <td><textarea name="html_correo_inicial" cols="32" rows="5" value="<?php echo htmlentities($row_rsCampanna['html_correo_inicial'], ENT_COMPAT, ''); ?>"><?php echo $row_rsCampanna['html_correo_inicial']; ?></textarea></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Update record">
      <a href="campannas_listado_vista.php" target="_self">Cancelar</a></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="idcampanna" value="<?php echo $row_rsCampanna['idcampanna']; ?>">
</form>
<p>&nbsp;</p>
